<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../../plugins/layui/css/layui.css">
</head>

<body>
    <div class="layui-row">
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            <div class="grid-demo layui-bg-gray" style="height:30px;text-align: center;">患者姓名</div>
        </div>
        <div class="layui-col-xs4 layui-col-sm7 layui-col-md4">
            <div class="grid-demo layui-bg-gray" style="height:30px;text-align: center">患者年龄</div>
        </div>
        <div class="layui-col-xs4 layui-col-sm5 layui-col-md4">
            <div class="grid-demo layui-bg-gray" style="height:30px;text-align: center">性别</div>
        </div>
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            <div class="grid-demo layui-bg-blue" style="height:30px;text-align: center;" id="patientName"></div>
        </div>
        <div class="layui-col-xs4 layui-col-sm7 layui-col-md8">
            <div class="grid-demo layui-bg-green" style="height:30px;text-align: center" id="patientAge"></div>
        </div>
        <div class="layui-col-xs4 layui-col-sm5 layui-col-md4">
            <div class="grid-demo layui-bg-black" style="height:30px;text-align: center" id="patientSex"></div>
        </div>
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            <div class="grid-demo layui-bg-gray" style="height:30px;text-align: center;">身份信息</div>
        </div>
        <div class="layui-col-xs4 layui-col-sm7 layui-col-md8">
            <div class="grid-demo layui-bg-gray" style="height:30px;text-align: center">医生姓名</div>
        </div>
        <div class="layui-col-xs4 layui-col-sm5 layui-col-md4">
            <div class="grid-demo layui-bg-gray" style="height:30px;text-align: center" >科室</div>
        </div>
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            <div class="grid-demo layui-bg-blue" style="height:30px;text-align: center;" id="personCard"></div>
        </div>
        <div class="layui-col-xs4 layui-col-sm7 layui-col-md8">
            <div class="grid-demo layui-bg-green" style="height:30px;text-align: center" id="docName"></div>
        </div>
        <div class="layui-col-xs4 layui-col-sm5 layui-col-md4">
            <div class="grid-demo layui-bg-black" style="height:30px;text-align: center" id="sdeptName"></div>
        </div>
        <div class="layui-col-xs12 ">
            <div class="layui-bg-red" style="height:200px;text-align: center">
                <label class="layui-form-label">诊断信息</label>

                <!-- 提交表单 -->
                <div class="layui-form" >

                    <div class="layui-form-item layui-form-text">

                        <div class="layui-input-block" style="margin-left: 0px">
                            <textarea placeholder="请输入内容" class="layui-textarea" style="height: 240px" id="intro"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="demo1" id="submit">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <script src="../../plugins/jquery/jquery.min.js"></script>
    <script src="../../plugins/layui/layui.all.js"></script>
    <script>

        $(function () {

            var url = location.search;

            var obj = {};
            var reg = /\?/;
            if (url.match(reg)) {
                //判断传入参数，以问号截取，问号后是参数
                var chars = url.split('?')[1];

                //再截&号
                var arr = chars.split('&');

                //获得截取后的数组为键值对字符串
                for (var i = 0; i < arr.length; i++) {

                    //保守一点确定看是否为 name=value形式
                    var num = arr[i].indexOf("=");

                    if (num > 0) {
                        //拼接字符串
                        var name = arr[i].substring(0, num);
                        var value = arr[i].substr(num + 1);

                        //拼接对象，并转码
                        obj[decodeURIComponent(name)] = decodeURIComponent(value);
                    }
                }
            }

            console.log(obj)

            var patientName = document.getElementById("patientName").innerHTML=obj.patientName;
            var patientAge = document.getElementById("patientAge").innerHTML=obj.patientAge;
            var patientSex = document.getElementById("patientSex").innerHTML=obj.patientSex;
            var personCard = document.getElementById("personCard").innerHTML=obj.personCard;
            var docName = document.getElementById("docName").innerHTML=obj.docName;
            var sdeptName = document.getElementById("sdeptName").innerHTML=obj.sdeptName;
            var doctorId = obj.doctorId
            var patId = obj.patientId
            console.log(patientName)
            console.log(patientAge)
            console.log(patientSex)
            console.log(personCard)
            console.log(docName)
            console.log(sdeptName)
            console.log(doctorId)
            console.log(patId)

            $("#submit").click(function () {
                var intro = document.getElementById("intro").value;
                console.log(intro)
                $.ajax({
                    url:"/treatment/insertValue",
                    data:{patientName:patientName,patientAge:patientAge,patientSex:patientSex,personCard:personCard,docName:docName,sdeptName:sdeptName,intro:intro,doctorId:doctorId,patId:patId},
                    async:true,
                    cache:false,
                    type:"POST",
                    success:function (result) {

                        if(result.message == "保存成功"){
                            layer.msg("保存成功")
                        }
                    }
                })
            })
        })


    </script>
</body>

</html>